#<hide>
"""
filtergraph:

(LiveThread:livethread) --> {InfoFrameFilter:live_out_filter} -> {InfoFrameFilter:filter_2} -> {InfoFrameFilter:filter_3}
"""
#</hide>
#<hide>
import time
from valkka.core import *
#</hide>
"""<rtf>
In the previous example, we had a thread (LiveThread), feeding a single FrameFilter (InfoFrameFilter).  The "filtergraph" for this case looks like this:

::

    (LiveThread:livethread) --> {InfoFrameFilter:live_out_filter}

In this notation, threads are marked with normal parenthesis (), and FrameFilters with curly brackets {}.  Both class and instance names are included.

Next, let's chain some FrameFilters like this:

::

    (LiveThread:livethread) --> {InfoFrameFilter:live_out_filter} -> {InfoFrameFilter:filter_2} -> {InfoFrameFilter:filter_3}
    
That chain can be created in python like this:
<rtf>"""
filter_3        =InfoFrameFilter("filter_3")
filter_2        =InfoFrameFilter("filter_2",filter_3)
live_out_filter =InfoFrameFilter("live_out_filter",filter_2)

"""<rtf>
Note that creating the filtergraph programmatically is started from the last framefilter ("filter_3"): we need to create "filter_3" first and pass it as a parameter (output target) to "filter_2", etc.  If you get confused with this, when dealing with more complex filtergraphs, just follow this rule of thumb: when instantiating framefilters, follow the filtergraph from end-to-beginning.

The output when running the python code looks like this:
    
::

    InfoFrameFilter: live_out_filter start dump>> 
    ...
    InfoFrameFilter: live_out_filter <<end dump   
    InfoFrameFilter: filter_2 start dump>> 
    ...
    InfoFrameFilter: filter_2 <<end dump   
    InfoFrameFilter: filter_3 start dump>> 
    ...
    InfoFrameFilter: filter_3 <<end dump   

So, live_out_filter gets frame from livethread.  It prints out info about the frame.  Then it passes it to filter_2 that again prints information about the frame.  filter_2 passes the frame onto filter_3, etc.

.. note:: LiveThread has an internal FrameFilter chain that is used to correct the timestamps given by your IP camera 
<rtf>"""
#<hide>
livethread =LiveThread("livethread")
ctx =LiveConnectionContext(LiveConnectionType_rtsp, "rtsp://admin:nordic12345@192.168.1.41", 1, live_out_filter)

livethread.startCall()
livethread.registerStreamCall(ctx)
livethread.playStreamCall(ctx)
time.sleep(5)
livethread.stopCall()

print("bye")
#</hide>
